import request from '@/utils/request'


// 1. 创建卷
export function createVolume(data) {
  // data包含: { creation_id, title, description }
  return request({
    url: "/api/v1/volumes/create",
    method: "POST",
    data
  });
}

// 2. 删除卷
export function deleteVolume(volumeId) {
  // 需POST + JSON体: { volume_id }
  return request({
    url: "/api/v1/volumes/delete",
    method: "POST",
    data: { volume_id: volumeId }
  });
}

// 3. 更新卷标题
export function updateVolumeTitle(volumeId, title) {
  return request({
    url: "/api/v1/volumes/edit/title",
    method: "POST",
    data: {
      volume_id: volumeId,
      title
    }
  });
}

// 4. 更新卷描述
export function updateVolumeDescription(volumeId, description) {
  return request({
    url: "/api/v1/volumes/update_description",
    method: "POST",
    data: {
      volume_id: volumeId,
      description
    }
  });
}

// 5. 更新卷编号
export function updateVolumeNumber(volumeId, newVolNum) {
  return request({
    url: "/api/v1/volumes/update_number",
    method: "POST",
    data: {
      volume_id: volumeId,
      new_vol_num: newVolNum
    }
  });
}

// 6. 移动卷
export function moveVolume(volumeId, targetVolumeId, position) {
  // position可取 "before" 或 "after"
  return request({
    url: "/api/v1/volumes/move",
    method: "POST",
    data: {
      volume_id: volumeId,
      target_volume_id: targetVolumeId,
      position
    }
  });
}

// 7. 获取卷列表
export function getVolumeList(creationId) {
  // POST + JSON体: { creation_id }
  return request({
    url: "/api/v1/volumes/list",
    method: "POST",
    data: { creation_id: creationId }
  });
}

// 8. 获取卷详情
export function getVolumeDetail(volumeId) {
  // POST + JSON体: { volume_id }
  return request({
    url: "/api/v1/volumes/detail",
    method: "POST",
    data: { volume_id: volumeId }
  });
}
export function volumeUpdate(volume_id,title, description) {
  return request({
    url: "/api/v1/volumes/update",
    method: "POST",
    data: {
      volume_id: volume_id,
      title:title,
      description: description
    }
  });
}
